/* GUI CONVERTED from reopex01.p (converter v1.75) Sat Aug 12 23:06:28 2000 */
/* reopex01.p - BUILD PK_DET FILE FOR COMPONENTS TO ISSUE FROM WOD_DET  */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                  */
/* All rights reserved worldwide.  This is an unpublished work.         */
/*F0PN*/ /*V8:ConvertMode=Maintenance                                   */
/*K1Q4*/ /*V8:WebEnabled=No                                             */
/* REVISION: 7.3       LAST EDIT: 11/06/92      MODIFIED BY: emb *G689* */
/* REVISION: 7.3       LAST EDIT: 03/01/94      MODIFIED BY: qzl *FM52* */
/* REVISION: 7.3       LAST EDIT: 03/04/94      MODIFIED BY: pma *FM46* */
/* REVISION: 7.3       LAST EDIT: 06/12/95      MODIFIED BY: dzs *G0PB* */
/* REVISION: 8.6       LAST EDIT: 05/20/98      BY: *K1Q4* Alfred Tan   */
/* REVISION: 9.1       LAST EDIT: 08/12/00      BY: *N0KP* myb          */


/*FM52*******************************************************************/
/*    THIS SHOULD HAVE BEEN PATCH FM46.  ADDED TO PATCH GROUP FM52      */
/*    PATCH FM52 IS UNDONE AND ORIGINAL PROGRAM RESUBMITTED             */
/*FM52*******************************************************************/


     define input parameter schedule_id as character.
     define input parameter operation like ps_op.
     define input parameter site like rps_site no-undo.
     define input parameter qty as decimal.
     define input parameter location as character.

     define shared variable mfguser as character.

     define variable iss_pol like mfc_logical.
     define variable i as integer.

/*G0PB*/ define variable wdays as integer no-undo.
/*G0PB*/ define shared workfile pkwkfl no-undo
/*G0PB*/    field pkrecid as recid
/*G0PB*/    field ltoff like ps_lt_off
/*G0PB*/    field isspol like mfc_logical.

/*G0PB*/ {mfdatev.i}

     for each wod_det no-lock where wod_lot = schedule_id
     and wod_op = operation:

        iss_pol = no.
        find pt_mstr where pt_part = wod_part no-lock no-error.
        if available pt_mstr then iss_pol = pt_iss_pol.

        find ptp_det no-lock where ptp_part = wod_part
        and ptp_site = site no-error.
        if available ptp_det then iss_pol = ptp_iss_pol.

        find in_mstr no-lock where in_part = wod_part
        and in_site = site no-error.

        find first pk_det exclusive where pk_user = mfguser
        and pk_part = wod_part
        and pk_reference = string(wod_op) no-error.
        if available (pk_det) then do:
           assign pk_qty = pk_qty + wod_qty_req / qty.
        end.
        else do:
/*G0PB         if iss_pol = yes then do:              */
          create pk_det.
          assign pk_user = mfguser
             pk_part = wod_part
            pk_reference = string(wod_op)
              pk_loc = location
/*FM46*                   pk_qty = wod_qty_req / qty. */
/*FM46*/                  pk_qty = wod_bom_qty.
          if pk_loc = "" and available in_mstr then pk_loc = in_loc.
          if pk_loc = "" and available pt_mstr then pk_loc = pt_loc.
/*G0PB         end.                                   */

/*G0PB*/       /* CREATE pkwkfl FOR FLOOR STOCK ITEMS */
/*G0PB*/       if iss_pol = no then do:
/*G0PB*/          wdays = 0.
/*G0PB*/          find first wo_mstr where wo_lot = wod_lot no-lock no-error.
/*G0PB*/          if available wo_mstr then do:
/*G0PB*/             {mfwday.i wo_rel_date wod_iss_date wdays wo_site}.
/*G0PB*/          end.

/*G0PB*/          create pkwkfl.
/*G0PB*/          assign pkrecid = recid(pk_det)
/*G0PB*/          ltoff = wdays
/*G0PB*/          isspol = iss_pol.
/*G0PB*/       end.
        end.
     end.
